import java.util.Scanner;

/**
 * 用户服务
 *
 * @author yuwei
 * @date 17:09 2024/4/24
 */
public class employeeManage {
     public static Boolean find(String name){
        for(Employee employee:employeeTable.employees){
            if(employee.getName().equals(name)){
                return true;
            }
        }
        return false;
    }

    public static void delete()
    {
        for(int i =1; i<= employeeTable.employees.size();i++){
            System.out.println(i+"."+employeeTable.employees.toArray()[i-1]);
        }
        if(employeeTable.employees.size()==0){
            System.out.println("    无任何数据 ");
            return;
        }
        System.out.println("请输入要删除的员工编号");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        if (num>0&&num<=employeeTable.employees.size())
        {

            employeeTable.employees.remove(num-1);
            System.out.println("删除成功");
        }
        else
        {
            System.out.println("输入错误");
        }
    }
    public static void add()
    {
        if(positionTable.positions.size()==0){
            System.out.println("    还未添加岗位 ");
            return;
        }
        System.out.println("--添加岗位--");
        departmentManage.show();

        System.out.println("输入部门名称");
        Scanner scan = new Scanner(System.in);
        String name = scan.next();
        positionManage.show();
        System.out.println("输入岗位名称");
        String name2 = scan.next();
        System.out.println("输入员工姓名");
        String name3 = scan.next();

        if (employeeTable.employees.add(new Employee(name,name2,name3)))
        {
            System.out.println("添加成功");
        }
        else
        {
            System.out.println("添加失败,该员工可能已经存在");
        }
    }
    public static void show() {
        if(employeeTable.employees.size()==0){
            System.out.println("    无任何数据 ");
            return;
        }
        employeeTable.employees.forEach(System.out::println);
    }
}
